package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class NewForDemo {
    public static void main(String[] args) {
        String[] array={"one","two","three","four","five"};
        for (int i = 0; i < array.length; i++) {
            String e=array[i];
            System.out.println(e);
        }
        System.out.println("------------");
        for (String s : array) {
            System.out.println(s);
        }
        System.out.println("————————————————集合————————————");

        Collection<String> c1=new ArrayList<>();
        c1.add("one");
        c1.add("#");
        c1.add("two");
        c1.add("#");
        c1.add("three");
        c1.add("#");
        c1.add("four");
        c1.add("#");
        c1.add("five");

        for (String s : c1) {
            System.out.println(s);
        }
        System.out.println("构造器");
//        Iterator<String> i2=c1.iterator();
         Iterator i1 = c1.iterator();
        while (i1.hasNext()){
            String s1 = (String) i1.next();
            System.out.println(s1);
            if ("#".equals(s1)){
                i1.remove();
            }
        }
        System.out.println(c1);
    }
}
